const mongoose = require("mongoose")
const crypto = require("crypto") //引用加密模块
const ObjectId = mongoose.Schema.Types.ObjectId;
const SupplierSchema = new mongoose.Schema({
    // 供应商详情数据模型

    name: String, //供应商名字
    address: String, //供应商地址
    phone: String, //供应商电话
    website: String, //供应商网址
    url: String, //供应商营业执照照片
    desc: String   //供应商备注
}, {
        versionKey: false,
        timestamps: {
            createdAt: 'createTime',
            updatedAt: 'updateTime'
        } //自动管理修改时间
    })
const supplier = mongoose.model("supplier", SupplierSchema);
async function add() {
    const count = await supplier.countDocuments();
    // console.log(count);
    if(count === 0){
        supplier.create({
            name:"测试数据",
            address:"成都市",
            phone:"12123124123",
            website:"www.666.com",
            url:"asdasfasf/dsadasd/",
            desc:"safasfsdfds"
        })
    }
}
add();
module.exports = supplier;
